package org.jg.arkanoid.gameobjects.factories;

import org.jg.arkanoid.bonuses.Guns;
import org.jg.arkanoid.gameobjects.Ball;
import org.jg.arkanoid.gameobjects.Brick;
import org.jg.arkanoid.gameobjects.Carriage;
import org.jg.arkanoid.gameobjects.GameObject;
import org.jg.arkanoid.gameobjects.objectpanel.BallPanel;
import org.jg.arkanoid.gameobjects.objectpanel.BrickPanel;
import org.jg.arkanoid.gameobjects.objectpanel.CarriagePanel;
import org.jg.arkanoid.gameobjects.objectpanel.GunsPanel;

public class ObjectPanelFactory {
	
	private static ObjectPanelFactory factoryInstance; 
	
	private ObjectPanelFactory(){}
	
	public static ObjectPanelFactory getFactoryInstance()
	{
		if(factoryInstance != null)
			return factoryInstance;
		
		synchronized(ObjectPanelFactory.class)
		{
			factoryInstance = new ObjectPanelFactory();
			return factoryInstance;
		}
	}
	
	public void setPanel(GameObject object){
		
		if(object instanceof Ball)
			setBallPanel((Ball)object);
		else if(object instanceof Carriage)
			setCarriagePanel((Carriage)object);
		else if(object instanceof Brick)
			setBrickPanel((Brick)object);
		else if(object instanceof Guns)
			setGunsPanel((Guns)object);
	}
	
	private void setBallPanel(Ball ball){
		ball.setPanel(new BallPanel(ball));
	}
	
	private void setCarriagePanel(Carriage carriage){
		carriage.setPanel(new CarriagePanel(carriage));
	}
	
	private void setBrickPanel(Brick brick){
		brick.setPanel(new BrickPanel(brick));
	}
	
	private void setGunsPanel(Guns guns){
		guns.setPanel(new GunsPanel(guns));
	}
}
